package com.sybkl.bigdatastudentmybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sybkl.bigdatastudentmybatisplus.controller.dto.UserDTO;
import com.sybkl.bigdatastudentmybatisplus.entity.User;
import com.sybkl.bigdatastudentmybatisplus.mapper.UserMapper;
import com.sybkl.bigdatastudentmybatisplus.service.UserService;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {


    @Override
    public boolean login(UserDTO userDTO) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", userDTO.getUsername()).eq("password", userDTO.getPassword());
        User one = getOne(queryWrapper);
        if (ObjectUtils.isEmpty(one)) {
            return false;
        } else {
            return true;
        }
    }

}
